﻿INSERT INTO iPerform.DiaryEntry (OwnerId, Created, LastModified, [Text], Name)
select 
UserId,
Created, 
Created, 
Value as Content,
'' as Name
from 
(select 
UserId,
Created, 
Created as LastModified, 
Value,
PATINDEX('%,"Content":"%',Value)  ContentIndex,
PATINDEX('%,"Name":"%',Value) NameIndex
FROM Settings.Parameters
where [Type]= 'InvestmentIntelligence.Engine.MessageReceiver.NotepadRecord'
AND Value <> '' ) Diaries
where ContentIndex=NameIndex

GO
DELETE
FROM Settings.Parameters
where [Type]= 'InvestmentIntelligence.Engine.MessageReceiver.NotepadRecord'
AND Value <> ''
AND PATINDEX('%,"Content":"%',Value) = PATINDEX('%,"Name":"%',Value)